﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace adonet_exercise
{
    class Program
    {
        static void Main(string[] args)
        {
            var sqlCon = "server =DESKTOP - 1D8K52G\\SQLEXPRESS; database = Blogs; uid = sa; pwd = DWYRYJZ1313323/";
            SqlConnection sqlConnection = new SqlConnection(sqlCon);

            sqlConnection.Open();

           

            SqlCommand sqlCommand = new SqlCommand("select * from commodity", sqlConnection);
            var reade = sqlCommand.ExecuteReader();

            Console.WriteLine("{0}\t\t{1}\t{2}\t{3}\t{4}\t{5}", "商品ID",  "商品名", "价格", "库存", "厂家ID", "类型ID");
            while (reade.Read())
            {
                    Console.WriteLine("{0}\t{1}\t{2}\t{3}\t{4}\t{5}",
                    reade["commodityId"], reade["commodityName"], reade["price"], reade["inventory"], reade["FactoryId"], reade["genreId"]);
            }

                    sqlConnection.Close();
        }
    }
}
